﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ValidationEngine.Commons.Enums;
using ValidationEngine.Tools;
using ValidationEngine.ValidationRules;

namespace ValidationEngineXTest.Models.Validators
{
    internal class ProductValidator : BaseValidator<Product>
    {
        public ProductValidator()
        {
            AddRule(Property(x => x.Name), new RequiredRule(defErrorText: "Name is required!", ruleApplingContext: RuleApplingContext.OnSave));
            AddRule(Property(x => x.Name), new MaxLengthRule(2, defErrorText: "Max length should be 2", ruleApplingContext: RuleApplingContext.Always));
        }
    }
}